{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Category Plots, aka Bar Charts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [1, 3, 5]])\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the initWidth and initHeight properties"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cplot = new CategoryPlot(initWidth: 400, initHeight: 200)\n",
    "def bars = new CategoryBars(value:[[1, 2, 3], [1, 3, 5]])\n",
    "cplot << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the title, x and y axis labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cplot = new CategoryPlot(title: \"Hello CategoryPlot!\",\n",
    "                             xLabel: \"Categories\",\n",
    "                             yLabel: \"Values\")\n",
    "cplot << new CategoryBars(value:[[1, 2, 3], [1, 3, 5]])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the category labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cplot = new CategoryPlot(categoryNames: [\"Helium\", \"Neon\", \"Argon\"])\n",
    "cplot << new CategoryBars(value: [[1, 2, 3], [1, 3, 5]])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the series labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2], [3, 4], [5, 6], [7, 8]],\n",
    "                            seriesNames: [\"Gas\", null, \"\", \"Liquid\"])\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the legend"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot = new CategoryPlot(showLegend: true) // force legend display\n",
    "def bars = new CategoryBars(value: [[1, 2, 3], [1, 3, 5]])\n",
    "// since no display names were provided, default names \"series0\" etc will be used.\n",
    "plot << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the orientation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot = new CategoryPlot(orientation: PlotOrientationType.HORIZONTAL)\n",
    "plot << new CategoryBars(value:[[1, 2, 3], [1, 3, 5]])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the label angle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot = new CategoryPlot(categoryNames: [\"Acid\", \"Neutral\", \"Base\"], \n",
    "                            categoryNamesLabelAngle: -1/4 * Math.PI)\n",
    "plot << new CategoryBars(value: [[1, 2, 3], [4, 5, 6]])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the margin"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "new CategoryPlot(categoryMargin: 2) << new CategoryBars(value: [[1, 2, 3], [4, 5, 6]])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the color (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2], [3, 4], [5, 6]], \n",
    "                            color: Color.pink)\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the color (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def colors = [Color.pink, [Color.red, Color.gray, Color.blue]]\n",
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]], \n",
    "                            color: colors)\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the base (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]], \n",
    "                            base: -2)\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the base (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            base: [-2, [-4, -4, -1]])\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the width (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            width: 0.3)\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the width (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            width: [[0.3, 0.6, 1.7], 1.0])\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the fill (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            fill: false)\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the fill (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            fill: [[false, true, false], true])\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "draw outline (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            drawOutline: true)\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "draw otline (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            drawOutline: [[false, true, false], true])\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "outline color (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            drawOutline: true,\n",
    "                            outlineColor: Color.green)\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "outline color (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],\n",
    "                            drawOutline: true,\n",
    "                           outlineColor: [Color.green, Color.red])\n",
    "new CategoryPlot() << bars"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Groovy",
   "language": "groovy",
   "name": "groovy"
  },
  "language_info": {
   "codemirror_mode": "groovy",
   "file_extension": ".groovy",
   "mimetype": "",
   "name": "Groovy",
   "nbconverter_exporter": "",
   "version": "2.5.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": false,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": false,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
